#ifndef __DEVICE_TREE_NANO_IOCTL_H
#define __DEVICE_TREE_NANO_IOCTL_H
#include <stddef.h>
#include <stdint.h>

#include "rtthread.h"

enum IOCTL_enum{
    /**
     * @param uint8_t* buf 
     * @param uint32_t Maximun Read Size(buf size)
     * @retval Data len read
     */
    IOCTL_READ =  0x00000000,
    /**
     * @param uint8_t *buf
     * @param uint32_t len
     * @retval len writed
     */
    IOCTL_WRITE,
    /**
     * @brief same as IOCTL_READ
     */
    IOCTL_ASYNC_READ,
    /**
     * @brief same as IOCTL_WRITE
     */
    IOCTL_ASYNC_WRITE,
    /**
     * @param struct io_xxx_cfg_t *
     * @param uint32_t sizeof(struct)
     */
    IOCTL_INIT,
    /**
     * @brief No param
     */
    IOCTL_START,
    /**
     * @brief No param
     */
    IOCTL_SUSPEND,
    /**
     * @brief No param
     */
    IOCTL_STOP,
    /**
     * @brief No param
     */
    IOCTL_DEINIT,
    /**
     * @param struct io_xxx_cfg_t *
     * @param uint32_t sizeof(struct)
     */
    IOCTL_GET_CFG,
    /**
     * @param struct io_xxx_cfg_t *
     * @param uint32_t sizeof(struct)
     */
    IOCTL_SET_CFG
};

/**************************************Serial****************************************/
enum serial_notify_event{
    IOCTL_NOTIFY_EVENT_SERIAL_RX_DONE = 0,  
    IOCTL_NOTIFY_EVENT_SERIAL_TX_DONE,  
    IOCTL_NOTITY_EVENT_SERIAL_FRAME_ERR 
};

struct io_event
{
    void *sender;
    int notify_event;
};

typedef void (*io_notify_cb_t)(struct io_event event);

typedef struct io_serial_cfg
{
    uint32_t baud;
    uint8_t  *rx_buf;
    size_t   rx_buf_len;
    uint8_t  *tx_buf;
    size_t   tx_buf_len;
    io_notify_cb_t notify_cb;
}io_serial_cfg_t;
    
#endif
